package com.honghe.mapper;

import com.github.pagehelper.Page;
import com.honghe.annotation.AutoFill;
import com.honghe.dto.DoctorDTO;
import com.honghe.dto.DoctorPageDTO;
import com.honghe.entity.Doctor;
import com.honghe.enumeration.OperationType;
import com.honghe.vo.DoctorPageVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface DoctorMapper {
    @Select("select * from doctor where username = #{username};")
    Doctor getByUsername(String username);
    @Select("select * from doctor where dept_id=#{deptId};")
    List<Doctor> getByDeptId(Long deptId);
    Page<DoctorPageVO> page(DoctorPageDTO doctorPageDTO);
    @Select("select * from doctor where id = #{id};")
    Doctor getById(Long id);
    @AutoFill(OperationType.INSERT)
    void insert(Doctor doctor);
    @AutoFill(OperationType.UPDATE)//自动填充更新时间
    void update(Doctor doctor);
    @Delete("delete from doctor where id = #{id};")
    void deleteById(Long id);
    @Update("update doctor set password = #{newPassword} where id = #{id} ;")
    void updatePassword(Long id, String newPassword);

}
